package Math;

public class _453_MinimumMovestoEqualArrayElements {
    //note: add 1 to n-1 elements is the same as subtract 1 from one element,so the minimum moves
    //to equal them all is to subtract them all to the smallest num.
    public int minMoves(int[] nums) {
        int ans = 0;
        int min = nums[0];
        for (int num : nums) {
            min = Math.min(min, num);
        }
        for (int num : nums) {
            ans += num - min;
        }
        return ans;
    }
}
